﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace Fitment.App_Code
{
    public class Data_Pop
    {
        DS data = new DS();  //建立数据库连接
        //private string sql; //表示控制的sql语句
        /// <summary>
        /// 获取用户工程信息(参数是房子编号)
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public DataTable getProject(int id)
        {
            string sql = "SELECT count(*)FROM ProjectInfo WHERE House_ID='" + id + "'";
            DataTable table = data.GetDataSource(sql, "query");
            return table;
        }
        /// <summary>
        /// 获取延期工程信息,此处规定在工程开始前10天开始提醒（此时为房间ID）
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public DataTable getDelay(int id)
        {
            //用于提醒用户10天内去买材料
            string sql = "SELECT *FROM ProjectInfo WHERE '" + DateTime.Now + "'-StartDate<10 AND State='N' AND House_ID='" + id + "'";
            DataTable table = data.GetDataSource(sql, "query");
            return table;
        }
        /// <summary>
        /// 用于获取用户信息（参数是用户ID）
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public DataTable getUserInfo(int id)
        {

            string sql = "SELECT * FROM UserInfo WHERE User_ID='" + id + "'";
            DataTable table = data.GetDataSource(sql, "query");
            return table;
        }

        /// <summary>
        /// 用于返回房子编号（参数是用户ID）
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataTable getHouse(int id)
        {
            string sql = "SELECT House_ID FROM HouseInfo WHERE User_ID='" + id + "'";
            DataTable table = data.GetDataSource(sql, "query");
            return table;
        }
    }
    
}
